package blog.action;

import java.util.HashMap;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import com.github.pagehelper.PageInfo;
import blog.entity.Article;
import blog.enums.ArticleStatus;
import blog.service.ArticleService;

@Controller
public class IndexAction {

    @Resource
    private ArticleService articleService;

    @RequestMapping(value = {"/", "/article"})
    public String index(@RequestParam(required = false, defaultValue = "1") Integer pageIndex,
                        @RequestParam(required = false, defaultValue = "10") Integer pageSize, Model model) {

        HashMap<String, Object> paramMap = new HashMap<>(1);
        paramMap.put("status", ArticleStatus.PUBLISH.getValue());
        
        //文章列表
        PageInfo<Article> articleList = articleService.getPageArticleList(pageIndex, pageSize, paramMap);
        model.addAttribute("pageInfo", articleList);
      
        return "index";
    }

   
}

